var express = require('express');
var router = express.Router();
var QuestModel = require('../db/questModel')

module.exports = function (req, res) {
    var user = req.user
    var id = req.params.id
    QuestModel.findOne({"id": id}, function (error, quest) {
        if (quest != null) {
            if (user.username !== quest.username) {
                res.status(400).send({
                    status: 400,
                    message: "用户不匹配"
                })
            } else {
                res.send({
                    title: quest.title,
                    description: quest.description,
                    questions: quest.questions
                })
            }
        } else {
            res.status(400).send({
                status: 400,
                message: "问卷不存在"
            })
        }
    })
}